#!/usr/bin/ruby
require 'rubygems'
require 'quotes.rb'
require 'mysql'

quotes = Quotes.new("localhost", "cgp", "sprinkler", "binks")

puts "All Prices:"
res = quotes.getprice("AAPL")
res.each_hash do |row|
  puts "#{row["last_trade_date"]} : #{row["last_price"]}"
end

puts "Prices in Range:"
res = quotes.getpriceinrange("AAPL", "2012-03-29", "2012-04-05")
res.each_hash do |row|
  puts "#{row["last_trade_date"]} : #{row["last_price"]}"
end

puts "Average Price in Range:"
res = quotes.getaveragepriceinrange("AAPL", "2012-03-29", "2012-04-05")
puts res

puts "Performance: "
res = quotes.computeperf("AAPL", 180.0, 10.0)
puts res
quotes.computeandstoreperf("AAPL", 180.0)

quotes.generateperf("NASDAQ")
quotes.close()